<%@page import="java.util.List"%>
<%@page import="database.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/Project1/layui-v2.6.13/layui/css/layui.css"/>
		<style>
			tr{
				height: 50px;
			}
		</style>
		<script type="text/javascript" src="/Project1/layui-v2.6.13/layui/layui.js"></script>
		<script type="text/javascript" src="/Project1/js/jquery-1.9.1.min.js"></script>
	</head>
	<body>
	<%
	String sql = Student.sqlSel(request.getParameter("id"));
	List<Student> list = DP.update(Student.class, sql, null);
	Student stu = list.get(0);
	%>
	<%request.setAttribute("stu", stu); %>
		<div style="padding: 20px; width: 90%; margin: 0 auto;">
			<form class="layui-form" id="form">
				<input value="<%=stu.getId() %>" name="id" type="hidden">
				<table>
					<tr>
						<td>姓名：</td>
						<td><input type="text" value="<%=stu.getName() %>" class="layui-input" name="name" id="name"></td>
						<td colspan="2">
							&nbsp;&nbsp;
							男<input type="radio" value="1" name="sex" <c:if test="${stu.sex==1}">checked</c:if> >
							女<input type="radio" value="0" name="sex" <c:if test="${stu.sex==0}">checked</c:if> >
						</td>
					</tr>
					<tr>
						<td>年级：</td>
						<td><input type="text" value="${stu.grade }" class="layui-input" name="grade"></td>
					</tr>
					<tr>
						<td>学院：</td>
						<td>
							<select name="c_id">
								<option value="" >学院</option>
								<option value="1" <c:if test="${stu.c_id==1}">selected="selected"</c:if>>计算机学院</option>
								<option value="2" <c:if test="${stu.c_id==2}">selected="selected"</c:if>>经济与管理学院</option>
								<option value="3" <c:if test="${stu.c_id==3}">selected="selected"</c:if>>外国语学院</option>
								<option value="4" <c:if test="${stu.c_id==4}">selected="selected"</c:if>>建筑工程学院</option>
								<option value="5" <c:if test="${stu.c_id==5}">selected="selected"</c:if>>机电学院</option>
							</select>
						<td>&nbsp;&nbsp;专业：</td>
						<td>
							<select name="m_id">
								<option value="">专业</option>
								<option value="1" <c:if test="${stu.m_id==1}">selected="selected"</c:if>>计算机科学与技术</option>
								<option value="2" <c:if test="${stu.m_id==2}">selected="selected"</c:if>>电子信息工程</option>
								<option value="3" <c:if test="${stu.m_id==3}">selected="selected"</c:if>>信息与计算科学</option>
								<option value="4" <c:if test="${stu.m_id==4}">selected="selected"</c:if>>通信工程</option>
								<option value="5" <c:if test="${stu.m_id==5}">selected="selected"</c:if>>物联网</option>
							</select>
						</td>
					</tr>
					<tr>
						<td>班级：</td>
						<td><input type="text" value="${stu.classs }" class="layui-input" name="classs"></td>
						<td>&nbsp;&nbsp;就业城市：</td>
						<td><input type="text" value="${stu.city }" class="layui-input" name="city"></td>
					</tr>
					<tr>
						<td>就业单位：</td>
						<td><input type="text" value="${stu.company }" class="layui-input" name="company"></td>
						<td>&nbsp;&nbsp;岗位：</td>
						<td><input type="text" value="${stu.job }" class="layui-input" name="job"></td>
					</tr>
					<tr>
						<td>薪资：</td>
						<td><input type="text" value="${stu.money }" class="layui-input" name="money"></td>
					</tr>
					<tr>
						<td>企业类型：</td>
						<td colspan="3">
							私企<input type="radio" value="1" name="type" <c:if test="${stu.type==1}">checked</c:if> >
							国企<input type="radio" value="2" name="type" <c:if test="${stu.type==2}">checked</c:if> >
							集体企业<input type="radio" value="3" name="type" <c:if test="${stu.type==3}">checked</c:if> >
							事业单位<input type="radio" value="4" name="type" <c:if test="${stu.type==4}">checked</c:if> >
							科研院所<input type="radio" value="5" name="type" <c:if test="${stu.type==5}">checked</c:if> >
						</td>
					</tr>
				</table>
			</form>
			<br>
			<button class="layui-btn layui-btn-fluid" onclick="gb()">更新</button>
		</div>
	</body>
	<script>		
		layui.use(['laydate','layer'], function(){
			var laydate = layui.laydate;
			var layer = layui.layer;
			
			//执行一个laydate实例
			laydate.render({
				elem: '#d1', //指定元素
				type : 'datetime'
			});
		});
		function gb(){
			
			var form = $("#form").serialize();
			$.ajax({
				url:"<%=request.getContextPath()%>/s",
				type:"post",
				data:"method=update&"+form,
				success:function(obj){
					
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index);
				}
			});
			
		}
		
		
	</script>
</html>






